package com.smartbus.bus.domain.dto;

import java.math.BigDecimal;
import java.util.Date;

/**
 * 调度系统车辆数据传输对象
 * 包含实时位置、状态等信息
 *
 * @author smartbus
 * @date 2025-09-24
 */
public class DispatchVehicleDTO {

    /** 车辆ID */
    private Long id;

    /** 车牌号码 */
    private String plateNumber;

    /** 公交车编号 */
    private String busNumber;

    /** 当前线路ID */
    private Long routeId;

    /** 线路名称 */
    private String routeName;

    /** 当前地图X坐标 */
    private Integer currentX;

    /** 当前地图Y坐标 */
    private Integer currentY;

    /** 当前GPS经度 */
    private BigDecimal currentLongitude;

    /** 当前GPS纬度 */
    private BigDecimal currentLatitude;

    /** 当前站点ID */
    private Long currentStationId;

    /** 当前站点名称 */
    private String currentStationName;

    /** 下一站点ID */
    private Long nextStationId;

    /** 下一站点名称 */
    private String nextStationName;

    /** 当前速度(km/h) */
    private BigDecimal speed;

    /** 车辆容量 */
    private Integer capacity;

    /** 当前乘客数 */
    private Integer currentPassengers;

    /** 车辆状态：running-运营中, stopped-停运, maintenance-维修中 */
    private String status;

    /** 状态文本 */
    private String statusText;

    /** 司机ID */
    private String driverId;

    /** 司机姓名 */
    private String driverName;

    /** 司机电话 */
    private String driverPhone;

    /** GPS设备ID */
    private String gpsDeviceId;

    /** 最后更新时间 */
    private Date lastUpdate;

    /** 行驶方向：up-上行, down-下行 */
    private String direction;

    /** 预计到达下一站时间(分钟) */
    private Integer etaNextStation;

    public DispatchVehicleDTO() {}

    public DispatchVehicleDTO(Long id, String plateNumber, String busNumber, Long routeId) {
        this.id = id;
        this.plateNumber = plateNumber;
        this.busNumber = busNumber;
        this.routeId = routeId;
        // 设置默认值
        this.status = "running";
        this.statusText = "运营中";
        this.speed = BigDecimal.ZERO;
        this.capacity = 50;
        this.currentPassengers = 0;
        this.direction = "up";
        this.lastUpdate = new Date();
    }

    // Getters and Setters
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getPlateNumber() {
        return plateNumber;
    }

    public void setPlateNumber(String plateNumber) {
        this.plateNumber = plateNumber;
    }

    public String getBusNumber() {
        return busNumber;
    }

    public void setBusNumber(String busNumber) {
        this.busNumber = busNumber;
    }

    public Long getRouteId() {
        return routeId;
    }

    public void setRouteId(Long routeId) {
        this.routeId = routeId;
    }

    public String getRouteName() {
        return routeName;
    }

    public void setRouteName(String routeName) {
        this.routeName = routeName;
    }

    public Integer getCurrentX() {
        return currentX;
    }

    public void setCurrentX(Integer currentX) {
        this.currentX = currentX;
    }

    public Integer getCurrentY() {
        return currentY;
    }

    public void setCurrentY(Integer currentY) {
        this.currentY = currentY;
    }

    public BigDecimal getCurrentLongitude() {
        return currentLongitude;
    }

    public void setCurrentLongitude(BigDecimal currentLongitude) {
        this.currentLongitude = currentLongitude;
    }

    public BigDecimal getCurrentLatitude() {
        return currentLatitude;
    }

    public void setCurrentLatitude(BigDecimal currentLatitude) {
        this.currentLatitude = currentLatitude;
    }

    public Long getCurrentStationId() {
        return currentStationId;
    }

    public void setCurrentStationId(Long currentStationId) {
        this.currentStationId = currentStationId;
    }

    public String getCurrentStationName() {
        return currentStationName;
    }

    public void setCurrentStationName(String currentStationName) {
        this.currentStationName = currentStationName;
    }

    public Long getNextStationId() {
        return nextStationId;
    }

    public void setNextStationId(Long nextStationId) {
        this.nextStationId = nextStationId;
    }

    public String getNextStationName() {
        return nextStationName;
    }

    public void setNextStationName(String nextStationName) {
        this.nextStationName = nextStationName;
    }

    public BigDecimal getSpeed() {
        return speed;
    }

    public void setSpeed(BigDecimal speed) {
        this.speed = speed;
    }

    public Integer getCapacity() {
        return capacity;
    }

    public void setCapacity(Integer capacity) {
        this.capacity = capacity;
    }

    public Integer getCurrentPassengers() {
        return currentPassengers;
    }

    public void setCurrentPassengers(Integer currentPassengers) {
        this.currentPassengers = currentPassengers;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
        // 自动更新状态文本
        switch (status) {
            case "running":
                this.statusText = "运营中";
                break;
            case "stopped":
                this.statusText = "停运";
                break;
            case "maintenance":
                this.statusText = "维修中";
                break;
            default:
                this.statusText = status;
        }
    }

    public String getStatusText() {
        return statusText;
    }

    public void setStatusText(String statusText) {
        this.statusText = statusText;
    }

    public String getDriverId() {
        return driverId;
    }

    public void setDriverId(String driverId) {
        this.driverId = driverId;
    }

    public String getDriverName() {
        return driverName;
    }

    public void setDriverName(String driverName) {
        this.driverName = driverName;
    }

    public String getDriverPhone() {
        return driverPhone;
    }

    public void setDriverPhone(String driverPhone) {
        this.driverPhone = driverPhone;
    }

    public String getGpsDeviceId() {
        return gpsDeviceId;
    }

    public void setGpsDeviceId(String gpsDeviceId) {
        this.gpsDeviceId = gpsDeviceId;
    }

    public Date getLastUpdate() {
        return lastUpdate;
    }

    public void setLastUpdate(Date lastUpdate) {
        this.lastUpdate = lastUpdate;
    }

    public String getDirection() {
        return direction;
    }

    public void setDirection(String direction) {
        this.direction = direction;
    }

    public Integer getEtaNextStation() {
        return etaNextStation;
    }

    public void setEtaNextStation(Integer etaNextStation) {
        this.etaNextStation = etaNextStation;
    }

    @Override
    public String toString() {
        return "DispatchVehicleDTO{" +
                "id=" + id +
                ", plateNumber='" + plateNumber + '\'' +
                ", routeId=" + routeId +
                ", status='" + status + '\'' +
                ", currentPassengers=" + currentPassengers +
                ", speed=" + speed +
                '}';
    }
}